*******************************************	   
************* TABLE A41 FR Historic gold production
	   

clear all
clear matrix
set more off

* Data
use "~/Dropbox/Replication_MVC/Datasets/datasets_analysis/panel_excombatientes.dta", clear 

sort id year
* Economic shock=. Interaction intensity*price
gen gold_shockCC= goldprod04*log_gold_price

* Define mean value of economic shock for the group
sort wartimenetwork
by wartimenetwork: egen mean_gold_productionCC=mean(goldprod04)
gen mean_gold_shockCC=mean_gold_productionCC*log_gold_price

* Standardize 
sum gold_shockCC
generate gold_shock_rCC = (gold_shockCC-r(mean))/r(sd)

sum mean_gold_shockCC
generate mean_gold_shock_rCC = (mean_gold_shockCC-r(mean))/r(sd)

eststo clear
set more off

* Main - Red-handed Captures 
reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC, absorb(wartimenetwork year origmun) vce(cluster wartimenetwork)
estadd local ALLFE = "$\checkmark$"
summ diffcaptures_f if e(sample) ==1
estadd local meanDep = trim("`: display %12.4fc `r(mean)''")
estadd local SDDep = trim("`: display %12.4fc `r(sd)''")
eststo

*  + Time trends
reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC time_t, absorb(wartimenetwork origmun year) vce(cluster wartimenetwork)
estadd local ALLFE = "$\checkmark$"
estadd local TT = "$\checkmark$"
summ diffcaptures_f if e(sample) ==1
estadd local meanDep = trim("`: display %12.4fc `r(mean)''")
estadd local SDDep = trim("`: display %12.4fc `r(sd)''")
eststo

*  + Region * Time 
reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC c.time_t##i.region, absorb(wartimenetwork year origmun) vce(cluster wartimenetwork)
estadd local ALLFE = "$\checkmark$"
estadd local TT = "$\checkmark$"
estadd local MT = "$\checkmark$"
summ diffcaptures_f if e(sample) ==1
estadd local meanDep = trim("`: display %12.4fc `r(mean)''")
estadd local SDDep = trim("`: display %12.4fc `r(sd)''")
eststo

*  + Municipality baseline covariate intercated with year
reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC c.time_t##i.region c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t , absorb(wartimenetwork year origmun) vce(cluster wartimenetwork)
estadd local ALLFE = "$\checkmark$"
estadd local TT = "$\checkmark$"
estadd local MT = "$\checkmark$"
estadd local BC = "$\checkmark$"
summ diffcaptures_f if e(sample) ==1
estadd local meanDep = trim("`: display %12.4fc `r(mean)''")
estadd local SDDep = trim("`: display %12.4fc `r(sd)''")
eststo

* + Ex-cobatants baseline covariates
reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC c.time_t##i.region age female black indigenous c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t, absorb(wartimenetwork year origmun ) vce(cluster wartimenetwork)
estadd local ALLFE = "$\checkmark$"
estadd local TT = "$\checkmark$"
estadd local MT = "$\checkmark$"
estadd local BC = "$\checkmark$"
estadd local CO = "$\checkmark$"
summ diffcaptures_f if e(sample) ==1
estadd local meanDep = trim("`: display %12.4fc `r(mean)''")
estadd local SDDep = trim("`: display %12.4fc `r(sd)''")
eststo

/*
* Table A22
esttab est* using "~/Dropbox/Replication_MVC/Paper_tables/TableA22_panelA.tex", se ///
	   star(* 0.10 ** 0.05 *** 0.01 ) ///
	   stats(meanDep SDDep N ALLFE TT MT BC CO, fmt(%12.4fc %12.4fc  %12.0fc %12.0fc %12.0fc %12.0fc %12.0fc %12.0fc) ///
	   label("\small Mean of Outcome" "\small S.D of Outcome" "\small Observations" "\small Municipality, Year, and Group FE" "\small Time Trends" "\small Region $\times$  Year" "\small Municipality Characteristics TT" ///
			"\small Individual Covariates" )) ///
	   keep() /// 
	   varlabels(gold_shock_rCC  "Economic Shock" mean_gold_shock_rCC "Average Shock" ) ///
	   ti("Economic Shock and Peer Effects for fragrant captures - Historic Gold Production - Full model ") ///	  
	   replace
*/	   
* Table A41
 esttab est* using "~/Dropbox/Replication_MVC/Paper_tables/TableA41.tex", se ///
 	   star(* 0.10 ** 0.05 *** 0.01 ) ///
 	   stats(meanDep SDDep N ALLFE TT MT BC CO, fmt(%12.4fc %12.4fc  %12.0fc %12.0fc %12.0fc %12.0fc %12.0fc %12.0fc) ///
 	   label("\small Mean of Outcome" "\small S.D of Outcome" "\small Observations" "\small Municipality, Year, and Group FE" "\small Time Trends" "\small Region $\times$  Year" "\small Municipality Characteristics TT" ///
 			"\small Individual Covariates" )) ///
 	   varlabels(gold_shock_rCC  "Economic Shock" mean_gold_shock_rCC "Average Shock" ) ///
 	   ti("Economic Shock and Peer Effects for fragrant captures - Historic Gold Production - Full model ") ///	  
 	   replace	   

/*
eststo clear
set more off

reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC, absorb(wartimenetwork year origmun) vce(cluster wartimenetwork)
nlcom _b[mean_gold_shock_rCC]/(_b[gold_shock_rCC] + _b[mean_gold_shock_rCC]), post
eststo

reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC time_t, absorb(wartimenetwork origmun year) vce(cluster wartimenetwork)
nlcom _b[mean_gold_shock_rCC]/(_b[gold_shock_rCC] + _b[mean_gold_shock_rCC]), post
eststo

reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC, absorb(wartimenetwork year origmun c.time_t##i.region) vce(cluster wartimenetwork)
nlcom _b[mean_gold_shock_rCC]/(_b[gold_shock_rCC] + _b[mean_gold_shock_rCC]), post
eststo

reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t , absorb(wartimenetwork year origmun c.time_t##i.region) vce(cluster wartimenetwork)
nlcom _b[mean_gold_shock_rCC]/(_b[gold_shock_rCC] + _b[mean_gold_shock_rCC]), post
eststo 

reghdfe diffcaptures_f gold_shock_rCC mean_gold_shock_rCC age female black indigenous c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t, absorb(wartimenetwork year origmun c.time_t##i.region) vce(cluster wartimenetwork)
nlcom _b[mean_gold_shock_rCC]/(_b[gold_shock_rCC] + _b[mean_gold_shock_rCC]), post
eststo

esttab est* using "~/Dropbox/Replication_MVC/Paper_tables/TableA22_panelB.tex", se ///
	   star(* 0.10 ** 0.05 *** 0.01 ) ///
	   stats(meanDep N, fmt(%12.4fc %12.0fc)) ///
	   keep(_nl_1 ) ///
	   varlabels( _nl_1 "Peer Effect") ///
	   ti("Economic Shock and Peer Effects") ///	  
	   replace	
